home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / prog_c / cuj0696.zip / DWYER.ZIP / RUN.TST / RUNMNSD.C < prev    next >
C/C++ Source or Header  |  1996-02-23  |  1KB  |  44 lines

  1. /* ============ */
  2. /* runmnsd.c    */
  3. /* ============ */
  4. #include <assert.h>
  5. #include <stdio.h>
  6. #include <miscdefs.h>
  7. #include <math.h>
  8.  
  9. /* ------------------- */
  10. /* FUNCTION PROTOTYPES */
  11. /* ------------------- */
  12. # undef F
  13. # if defined(__STDC__) || defined(__PROTO__)
  14. #    define  F( P )  P
  15. # else
  16. #    define  F( P )  ()
  17. # endif
  18.  
  19. /* INDENT OFF */
  20. extern    double    CalcHarm F((int, UINT));
  21.  
  22. # undef F
  23. /* INDENT ON */
  24.  
  25. /* ==================================================================== */
  26. /* RunMeanStdDev - Calculates Mean No. Variates & Std Dev. for Run Test    */
  27. /* ==================================================================== */
  28. void
  29. RunMeanStdDev(UINT SetSize, UINT Width, double *Mean, double *StdDev)
  30. {
  31.     /* --------------------------------------------------------- */
  32.     /* Width is maximum number of unique integers in a data set. */
  33.     /* These equations were taken from D. E. Knuth, "The Art of  */
  34.     /* Computer Programming," Volume 2, Seminumerical Algorithms */
  35.     /* (1981), page 536 (top).                     */
  36.     /* --------------------------------------------------------- */
  37.     assert(SetSize >= Width);
  38.     *Mean   = SetSize *
  39.         (CalcHarm(1, SetSize) - CalcHarm(1, SetSize - Width));
  40.     *StdDev = sqrt(SQR((double)SetSize)*
  41.         (CalcHarm(2, SetSize) - CalcHarm(2, SetSize - Width))
  42.         - *Mean);
  43. }
  44.